<template>
	<view class="index-page page">
		<view class="content">
			<loading v-if="showLoading"></loading>
			<view class="info-block">
				<template v-if="list.length>0">
					<view class="activity-item" v-for="(item,index) in list" :key="item.id">
						<view class="activity-top">
							<view class="top-left">
								<image
									src="https://job-1306862033.cos.ap-chengdu.myqcloud.com/miniprogram-static/alliance/bus2.png">
								</image>
								<view class="title">
									{{item.activityName}}
								</view>
							</view>
							<view class="top-right" v-if="item.status==1" style="color: #60DC4D;">
								待使用
							</view>
							<view class="top-right" v-if="item.status==2" style="color: #FF2F34;">
								待评价
							</view>
							<view class="top-right" v-if="item.status==4" style="color: #767676;">
								已取消
							</view>
						</view>
						<view class="activity-middle"
							@click="navigate('/page_other/activity/activityDetail?id='+item.activityId+'&latitude='+latitude+'&longitude='+longitude)">
							<image :src="cloudStorage+item.user.faceUrl" mode=""></image>
							<view class="middle-right">
								<view class="info-top">
									<view class="info-title">
										{{item.user.phone}}
									</view>
									<view class="involution">
										￥{{item.voucher}}券
									</view>
								</view>
								<view class="info-time">
									下单时间：{{item.createTime}}
								</view>
							</view>
						</view>
					</view>
				</template>
				<view v-if="more==false&&list.length==0" class="empty">暂无数据</view>
				<view v-else-if="more==false&&list.length>0" class="empty">没有更多了</view>
			</view>
		</view>
	</view>
</template>

<script>
	import CustomNav from '@/components/CustomNav/CustomNav';
	import Tabbar from '@/components/Tabbar/Tabbar';
	import {
		getBusinessGetOrdersApi
	} from '@/api/incom.js';
	import {
		isMore
	} from '@/util/util.js'
	import {
		validate
	} from '@/util/validate.js'
	import {
		getStorage
	} from '@/util/auth';
	export default {
		components: {
			Tabbar,
		},
		data() {
			return {
				verificationCode: '',
				status: '',
				state: 1,
				list: [],
				conf: {
					page: 1,
					limit: 10,
				},
				more: true,
				latitude: '',
				longitude: ''
			};
		},
		async onLoad(e) {
			this.type = e.type
			uni.setNavigationBarTitle({
				title: e.title
			});
			this.latitude = getStorage('latitude')
			this.longitude = getStorage('longitude')
			uni.showCustomLoading();
			Promise.all([this.getList(true)]).finally(() => {
				uni.hideCustomLoading()
			})
		},
		onShow() {},

		methods: {
			handleRefresh() {
				this.conf.page = 1;
				this.more = true
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				this.getList(true)
			},
			getList(refresh = false) {
				return getBusinessGetOrdersApi({
					page: this.conf.page,
					limit: this.conf.limit,
					type: this.type,
				}).then((res) => {
					let list = res.list || [];
					if (refresh) {
						this.list = list;

					} else {
						this.list = [...this.list, ...list]
					}
					this.more = isMore(this.conf.page, this.conf.limit, res.count)
				})
			},
		},
		onReachBottom() {
			if (this.more) {
				this.conf.page++;
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				this.getList();
			}
		},
	};
</script>

<style scoped lang="scss">
	.index-page {
		overflow: hidden;
		min-height: 100vh;
		background-color: #f7f6f9;

		.content {
			width: 100%;
			overflow-y: auto;
			position: relative;

			.info-block {
				position: relative;
				padding: 30rpx;

				.classify-tab-block {
					width: 100%;
					display: flex;
					justify-content: center;
					align-items: center;
					margin-bottom: 20rpx;

					.tab-content {
						display: flex;
						justify-content: space-between;

						.tab-item {
							padding: 10rpx;
							font-size: 30rpx;
							margin-right: 20rpx;
							flex: none;
							color: #FF2F34;
						}

						.tab-item.active {
							font-size: 32rpx;
							color: #FF2F34;
							font-family: 'FangZhengHanZhenGuangBiaoJianTi';
						}
					}

					.iconfont {
						font-size: 32rpx;
						font-weight: bold;
						color: #fff;
					}
				}

				.activity-item {
					padding: 24rpx 30rpx 20rpx;
					background-color: #FFFFFF;
					border-radius: 20rpx;
					margin-bottom: 20rpx;

					.activity-top {
						display: flex;
						justify-content: space-between;
						align-items: center;
						margin-bottom: 26rpx;

						.top-left {
							width: calc(100% - 100rpx);
							display: flex;
							align-items: center;

							image {
								width: 40rpx;
								height: 40rpx;
								margin-right: 10rpx;
							}

							.title {
								width: calc(100% - 50rpx);
								font-size: 30rpx;
								font-weight: bold;
								text-overflow: ellipsis;
								white-space: nowrap;
							}
						}

						.top-right {
							font-size: 30rpx;
						}
					}

					.activity-middle {
						display: flex;
						height: 120rpx;

						image {
							width: 80rpx;
							height: 80rpx;
							margin-right: 20rpx;
							border-radius: 60rpx;
							margin-top: 30rpx;
						}

						.middle-right {
							width: calc(100% - 140rpx);
							display: flex;
							flex-direction: column;
							justify-content: space-around;
							height: 120rpx;

							.info-top {
								width: 100%;
								display: flex;
								justify-content: space-between;



								.info-title {
									width: calc(100% - 150rpx);
									overflow: hidden;
									text-overflow: ellipsis;
									white-space: nowrap;
									font-size: 28rpx;
									margin-top: 10rpx;
								}

								.involution {
									width: 150rpx;
									text-align: end;
									font-weight: bold;
								}
							}

							.info-time {
								font-size: 28rpx;
							}
						}
					}

					.activity-bottom {
						display: flex;
						margin-top: 26rpx;
						display: flex;
						justify-content: flex-end;
						font-size: 30rpx;

						.cancel {
							padding: 10rpx 20rpx;
							border: 1px solid #767676;
							color: #767676;
							box-sizing: border-box;
							border-radius: 100rpx;
							margin-right: 20rpx;
						}

						.yard {
							padding: 10rpx 20rpx;
							border: 1px solid #FF2F34;
							box-sizing: border-box;
							border-radius: 100rpx;
							color: #FF2F34;
						}
					}

				}
			}

			.sign-pop {
				position: fixed;
				left: 0;
				top: 0;
				background: rgba(0, 0, 0, 0.2);
				z-index: 999999;
				width: 100vw;
				height: 100vh;

				.sign-block {
					width: calc(100% - 240rpx);
					height: 550rpx;
					background: #fff;
					z-index: 99;
					position: fixed;
					transform: translate(-50%, 0%);
					left: 50%;
					bottom: 29%;
					box-shadow: 0 0 6px 0px #dadada;
					border-radius: 30rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					padding: 30rpx;

					.sign-top {
						display: flex;
						justify-content: space-between;
						width: 100%;

						image {
							width: 40rpx;
							height: 40rpx;
						}
					}

					image {
						width: 100%;
					}
				}
			}

			.cancel-pop {
				position: fixed;
				left: 0;
				top: 0;
				background: rgba(0, 0, 0, 0.2);
				z-index: 999999;
				width: 100vw;
				height: 100vh;

				.cancel-block {
					width: 100%;
					padding: 30rpx;
					background: #fff;
					z-index: 99;
					position: fixed;
					bottom: 0;
					box-shadow: 0 0 6px 0px #dadada;
					border-radius: 30rpx;
					display: flex;
					flex-direction: column;

					.cancel-title {
						display: flex;
						justify-content: space-between;

						.title {
							font-size: 34rpx;
							font-weight: bold;
						}

						image {
							width: 40rpx;
							height: 40rpx;
						}
					}

					.cancel-info {
						margin-top: 30rpx;

						.cancel-list {
							display: flex;
							justify-content: space-between;
							line-height: 90rpx;

							.name {
								font-size: 32rpx;
							}
						}
					}

					.btn {
						background-color: #FF2F34;
						width: 60%;
						height: 80rpx;
						border-radius: 50rpx;
						color: #fff;
						display: flex;
						margin: 30rpx auto;
						border-radius: 60rpx;
						justify-content: center;
						align-items: center;
					}
				}
			}

			.empty {
				text-align: center;
			}
		}
	}
</style>